package org.example.fanruan;

/**
 * @author Yyming
 * Created by Yyming on 2021/4/23
 */
public class MinNode {

    class Node {
        public Object data;//数据
        public Node left; //左节点
        public Node right; // 右节点
    }

    private Node root;

    public Node nearParentNode(Node root, Node node1, Node node2) {
        if (root == null || root == node1 || root == node2) {
            return root;
        }
        Node l = nearParentNode(root.left, node1, node2);
        Node r = nearParentNode(root.right, node1, node2);
        return l != null && r != null ? root : l == null ? r : l;
    }
}
